<?
//<meta http-equiv="content-type" content="text/html; charset=utf-8">
include "head.php";
if ( $logged_id != "admin" ) exit;
?>
<style type="text/css">
<!--
.style1 {color: #999999}
-->
</style>
<p><a href="index.php">HOME</a> / <strong>View MRSTY</strong></p>
<p>
<form name="form1" method="post" action="">
CUI <input type="text" name="cui" size="8" maxlength="8" value="<?=$cui?>">
TUI <input type="text" name="tui" size="4" maxlength="4" value="<?=$tui?>">
<select name="show">
<?
if (!isset($show)) $show = "1000";
print_option("1000","1000",$show);
print_option("","ALL",$show);
?>
</select>
<input type="submit" name="Submit" value="Submit">
</form>
</p>
<p>&nbsp;</p>
<?
if ( $cui ) $where .= " and cui = '$cui'";
if ( $tui ) $where .= " and tui = '$tui'";
if ( $show ) $limit = " limit $show";
if ( $where ) {
	
	$sty_list = array();
	$query = "select * from MRSTY where 1 $where $limit";
	print_list_from_query($query);	

	$result = mysql_query($query) or die("\n<br>Query:$query\n<br>Error:".mysql_error());
	while( $row = mysql_fetch_array($result) ) {
		$sty_list[$row['TUI']] = true;
	}
	
	
	$str_val_list = array();
	$query = "select * from SRDEF where rt = 'STY' order by stn_rtn asc";
	$result = mysql_query($query) or die("\n<br>Query:$query\n<br>Error:".mysql_error());
	while( $row = mysql_fetch_array($result) ) {
		$tui = $row['UI'];
		$sty = $row['STY_RL'];
		$stn = $row['STN_RTN'];
		
		if ( $sty_list[$tui] ) $val = "<strong>$stn $sty ($tui)</strong>";
		else $val = "$stn $sty ($tui)";
		
		$str_val_list[$stn] = $val;
	}
	
	$tree = make_tree_parse_list($str_val_list);
	$tree["_value"] = "ROOT";
	echo "<p>";
	echo_tree($tree);
	echo "</p>";
}


?>
<p>&nbsp;</p>
<?
include "tail.php";
?>